<template>
    <div>
        <h3>我是列表页面</h3>
    </div>
    <table cellspacing="0" class="table" border="1">
        <thead>
        <tr>
            <th>品牌</th>
            <th>价格</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr v-for="(item, index) of data" :key="item.id">
            <td>{{ item.name }}</td>
            <td>{{ item.price }}</td>
            <td>
                <button @click="toDetail(item)">详情</button>
            </td>
        </tr>
        </tbody>
    </table>
</template>

<script>
import {data} from './list.json'

export default {
    data() {
        return {
            data: data
        }
    },
    methods: {
        toDetail(item) {
            // 使用query传参
            // this.$router.push({
            //     path: '/reg',
            //     query: item
            // })
            // 使用params传参
            this.$router.push({
                name: "Register",
                params: {
                    id: item.id
                }
            })
        }
    }
}
</script>

<st